﻿using Gumini.JulaDB.DataTypes;

namespace Gumini.JulaDB.Expressions.Operators
{
    internal class ConcatenateOperator : BinaryOperator
    {
        public ConcatenateOperator()
            : base("||") { }

        public override TypedValue Evaluate(TypedValue left, TypedValue right)
        {
            var varcharType = DataType.Varchar;
            return new TypedValue(varcharType,
                (string)varcharType.ConvertFrom(left.Value) +
                (string)varcharType.ConvertFrom(right.Value));
        }

        public override DataType GetReturnType()
        {
            return DataType.Varchar;
        }
    }
}
